﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Auction_Intranet.Models;
using AuctionDataLayer;

namespace Auction_Intranet.Controllers
{
    [HandleError]
    public class RoomsController : ParentController
    {
        DataRepository m_rep = new DataRepository();
        
        public ActionResult Index()
        {
            IEnumerable<Room> rooms = m_rep.GetAllRooms();
            List<RoomModel> model = new List<RoomModel>();
            
            foreach (var item in rooms)
            { 
                RoomModel room = new RoomModel();
                room.room = item;
                room.amenities = m_rep.GetAmenitiesByRoomBy(item.Id);
                room.pictures = m_rep.GetRoomPicturesByRoomId(item.Id);
                model.Add(room);
            }
            if (model != null)
            {
                return View(model);
            }
            return View();
        }
    }
}
